﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Data.SqlClient;

namespace finalexam
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Title = "欢迎来到学生信息管理系统";
        }

        protected void btnRead_Click1(object sender, EventArgs e)
        {
            String strCn = "server=pc.hstc.cn;database=dhd2014112134;uid=2014112134;pwd=19951124";
            SqlConnection cn = new SqlConnection(strCn);
            try
            {
                cn.Open();
                string strSql = "SELECT   Cource.*   FROM  Cource INNER JOIN Teacher ON Cource.Tno = Teacher.Tno";
                SqlCommand cmd = new SqlCommand(strSql, cn);
                SqlDataReader dr = cmd.ExecuteReader();
                this.GridView2.DataSource = dr;
                this.GridView2.DataBind();
                dr.Close();

            }
            catch (Exception ex)
            {
                this.Label3.Text = ex.Message;
            }
            finally
            {
                cn.Close();
            }
        }

        protected void btnRead1_Click(object sender, EventArgs e)
        {
            String strCn = "server=pc.hstc.cn;database=dhd2014112134;uid=2014112134;pwd=19951124";
            SqlConnection cn = new SqlConnection(strCn);
            try
            {
                cn.Open();
                string strSql = "SELECT   Cource.Cname , Cource.Time , Cource.Memo , Teacher.Tno, Teacher.Tname  FROM  Cource INNER JOIN Teacher ON Cource.Tno = Teacher.Tno  WHERE   (Cource.Cno = N'"+this.DDListCno.Text+"')";
                SqlCommand cmd = new SqlCommand(strSql, cn);
                SqlDataReader dr = cmd.ExecuteReader();
                this.GridView1.DataSource = dr;
                this.GridView1.DataBind();
                dr.Close();

            }
            catch (Exception ex)
            {
                this.Label3.Text = ex.Message;
            }
            finally
            {
                cn.Close();
            }
        }

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Session["Theme"] = this.DropDownList1.SelectedValue.ToString();
        }
        protected void Page_PreInit(object sender, EventArgs e)
        {
            if (Session["Theme"] != null)
                this.Theme = Session["Theme"].ToString();
        }
        

       
        
       
    }
}